package com.hengpeng.common.persist.entity;

import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.TableGenerator;

import com.hengpeng.common.persist.OperateLogListener;
import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputType;

/**
 * 此类以后逐步将被AbstractTableIdEntity所替代
 * 由于 valueColumnName = "COUNT" 中COUNT字段在MYSQL、HSQL等数据库上为关键字，不能使用
 * 故用AbstractTableIdEntity类所代替，改为valueColumnName = "COUNTSEQ"
 * 
 * @author zhaojitao
 *
 */
@MappedSuperclass
@Inheritance(strategy = InheritanceType.JOINED)
@EntityListeners(OperateLogListener.class)
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class AbstractTableAutoIdEntity extends AbstractEntity
{

	private static final long serialVersionUID = 7575289264917305323L;

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_SEQ")
	@TableGenerator(name = "TABLE_SEQ", table = "TABLE_SEQUENCES", allocationSize = 100, pkColumnName = "TABLENAME", valueColumnName = "COUNT")
	@HtmlInput(type = HtmlInputType.AUTOID)
	private Long id;

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}
}
